<?php
/**
 * Created by PhpStorm.
 * User: HuangLuSen
 * Date: 2017/5/12
 * Time: 17:36
 */

namespace app\admin\controller;


use app\common\model\Order;

use app\common\traits\SendMessage;
use think\Controller;
use think\Db;

class Test extends Controller
{
    use SendMessage;


    public function index(){
        $a = read('2222.xlsx','Excel2007');
        dump($a);
    }

//    public function chachong(){
//        $orders = Db::name('order')->where(['status'=>1,'yykf'=>0,'daoru'=>2])->field('id,maphone')->select();
//
//        $num = 0;
//        for($i=0;$i<=count($orders)-2;$i++){
//            for($j=$i+1;$j<=count($orders)-1;$j++){
//                if($orders[$i]['maphone'] == $orders[$j]['maphone'] ){
//                    $res = Db::name('order')->where(['id'=>$orders[$j]['id']])->update(['status'=>0]);
////                    echo "ID:{$orders[$i]['id']},maphone:{$orders[$i]['maphone']} ---- ID:{$orders[$j]['id']},maphone:{$orders[$j]['maphone']}<br/> ";
//                    dump($res);
//                    $num++;
//                }
//            }
//        }
//        echo $num;
//        halt('end');
//    }

    public function ceshitime(){
//        $time = date('n月j日',1511971200);
//        halt($time);

        $orders = Db::name('order')->where(['id'=>8383])->select();


        foreach ($orders as $info){
            $msgdata = [];
            if($info['qd_depar'] == 2){
                $yykf = Db::name('users')->where(['id'=>$info['jdry']])->find();
            }else{
                $yykf = getYykfInfo($info['yykf']);
            }
            $yycg = Db::name('group')->field('title')->where('id',$info['yycg'])->find();
            $msgdata['orderid'] = $info['id'];
            $msgdata['phone'] = '13012376008';
            $msgdata['param'] = ['yykf' => $yykf['username'],'timeyycg'=>date('n月j日',$info['yypstime']).$yycg['title']];
            $msgdata['tempcode'] = 'SMS_105190065';

            $result = $this->sendSmss($msgdata);

//            if($result){
//                Db::name('order')->where(['id'=>$info['id']])->setField('yyoneyuetsmsgflag',2);
//                $log = $this->getLogData($info);
//                $log['operation'] = 20;
//                Db::name('order_log')->insert($log);
//            }
        }
        echo "发送成功/n";
    }



}